/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package monitoring.general;

/**
 *
 * @author Katherine Moreno
 */


import java.sql.Timestamp;
import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.postgis.PGgeometry;
import system.general.Columna;

/**
 *
 * @author emojica
 */
@ManagedBean(name = "monitoring_generalBeans")
@ViewScoped
public class Beans {

    @Columna(nombre = "id", tipo = "Integer")
    private Integer id = 0;
    @Columna(nombre = "imei", tipo = "String")
    private String imei = "";
    private PGgeometry coordenadas;
    private Date fecha =new java.util.Date();
    @Columna(nombre = "trama", tipo = "String")
    private String trama = "";

    private user.login.Beans userBeans= new user.login.Beans();
    private gps.general.Beans gpsBeans= new gps.general.Beans();
    public Beans() {
    }

    public Beans(Integer id,String imei, Object object,Timestamp fecha, String trama) {
        this.id = id;
        this.imei = imei;
        this.coordenadas = (PGgeometry) object;
        this.fecha = new Date(fecha.getTime());
        this.trama = trama;
    }

    public void clearBeans() {
        setId(0);
        setImei("");
        setFecha(new java.util.Date());
        setTrama("");
        userBeans.clearBeans();
        gpsBeans.clearBeans();
    }

    private String strScape(String str) {
        str = str.trim();
        str = str.replace("'", "\'");
        str = str.replace("\\", "\\\\");
        return str;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return this.id;
    }

    public void setImei(String imei) {
        this.imei = imei;
    }

    public String getImei() {
        return this.imei;
    }
    public PGgeometry getCoordenadas() {
        return coordenadas;
    }

    public void setCoordenadas(PGgeometry coordenadas) {
        this.coordenadas = coordenadas;
    }
    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Date getFecha() {
        return this.fecha;
    }

    public void setTrama(String trama) {
        this.trama = strScape(trama);
    }

    public String getTrama() {
        return this.trama;
    }

    /**
     * @return the userBeans
     */
    public user.login.Beans getUserBeans() {
        return userBeans;
    }

    /**
     * @param userBeans the userBeans to set
     */
    public void setUserBeans(user.login.Beans userBeans) {
        this.userBeans = userBeans;
    }

    /**
     * @return the gpsBeans
     */
    public gps.general.Beans getGpsBeans() {
        return gpsBeans;
    }

    /**
     * @param gpsBeans the gpsBeans to set
     */
    public void setGpsBeans(gps.general.Beans gpsBeans) {
        this.gpsBeans = gpsBeans;
    }
    }
